package gipfProject.games.tzaar;

import gipfProject.games.tzaar.data.TzaarData;
import gipfProject.games.tzaar.engine.TzaarEngine;
import gipfProject.games.tzaar.gui.TzaarUI;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;

public class TzaarLauncher {
	static JFrame window;

	public static void launch() {
		// Create the game data
		TzaarData gameState = new TzaarData();

		// Create the game engine
		TzaarEngine engine = new TzaarEngine(gameState);

		// Create a new window with the title
		window = new JFrame("Tzaar - The GIPF Project");

		// Create the GUI
		TzaarUI gui = new TzaarUI(window, gameState, engine);

		// Load the GUI into this window
		window.setContentPane(gui);

		// Resize the window to match the contents
		window.pack();

		// Makes the window open in the middle of the screen
		Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
		window.setLocation((screensize.width - window.getWidth()) / 2,
				(screensize.height - window.getHeight()) / 2);

		// Set the program to terminate if this window is closed
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		// Disable resizing the window
		window.setResizable(false);

		// Make the window visible
		window.setVisible(true);
	}// End main
}
